package com.minelx.statementsplus.cha.core;

import com.minelx.landisk.filesystem.core.File;

import java.io.IOException;

public class MockChaSession implements IChaSession {
	@Override
	public ExplainResponse explain(String majorSql) {
		throw new UnsupportedOperationException("operation is unsupported.");
	}

	@Override
	public IChaTask createTask(TaskCommitment commitment, File destination) {
		return new IChaTask() {
			@Override
			public void execute() {
				try {
					String header = "loopId,majorSql,childSql,additionalValues,multipleValues\n";
					destination.write(header + commitment.loopId() + "," +
							commitment.majorSql() + "," +
							commitment.childSql() + "," +
							commitment.additionalValues() + "," +
							commitment.multipleValues());
				} catch (IOException e) {
					throw new RuntimeException("something is wrong here", e);
				}
			}

			@Override
			public long progress() {
				return 0;
			}
		};
	}
}
